//2009/08/15 19:02:04
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class NoisySensor
{
public:
    vector <int> medianFilter(vector <int> data)
    {
		vector<int> ans;
		ans.push_back(data[0]);
		for(int i=1; i<data.size()-1; i++)
		{
			int a[3];
			a[0] = data[i-1];
			a[1] = data[i];
			a[2] = data[i+1];
			sort(a, a+3);
			ans.push_back(a[1]);
		}
		if(data.size() > 1) ans.push_back(data[data.size() - 1]);
		return ans;
    }
};
